//
//  FindCar_Collection_ViewController.m
//  CarEncyclopedia
//
//  Created by lanou3g on 15/7/21.
//  Copyright (c) 2015年 ThighXingClub. All rights reserved.
//

#import "FindCar_Collection_ViewController.h"
#import "PicCell.h"
@interface FindCar_Collection_ViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@end

@implementation FindCar_Collection_ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    //布局
    UICollectionViewFlowLayout *layout=[UICollectionViewFlowLayout new];
    
    layout.minimumInteritemSpacing=5;
    layout.minimumLineSpacing=5;
    layout.itemSize=CGSizeMake(115, 85);
    
    layout.sectionInset=UIEdgeInsetsMake(10, 10, 10, 10);
    
    
    //创建collection对象
    UICollectionView *collectionView=[[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
    
    
    collectionView.delegate=self;
    collectionView.dataSource=self;
    
    [self.view addSubview:collectionView];
    
    
    //注册item
    [collectionView registerClass:[PicCell class] forCellWithReuseIdentifier:@"collectioncell"];
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



#pragma msrk --实现代理方法--

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 3;
    
}


-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    PicCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"collectioncell" forIndexPath:indexPath];
    
    cell.backgroundColor=[UIColor greenColor];
    
    
    return cell;
    
    
    
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
